<?php
declare(strict_types=1);
namespace app\admin\controller;
class Article extends Cp
{
    protected string $model = 'article';
    protected string $order = 'status ASC,is_top DESC,id DESC';
    protected string $listFieldExcept = 'markdown,html';
    protected array $stateList = ['status' => ['停用', '启用'], 'is_top' => ['取消置顶', '设置置顶']];

    protected function _where(): array
    {
        $where = [];
        $title = input('title', '', 'clear_html');
        if (!empty($title)) {
            $where[] = ['title LIKE ?', ['%' . $title . '%']];
        }
        $category_id = input('category_id', 0, 'intval');
        if ($category_id > 0) {
            $where['category_id'] = $category_id;
        }
        return $where;
    }
}